#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <pthread.h>
#include "random.h"

void random_setup_test() {
  setup_random_environment();
  setup_rng("exponential", cJSON_Parse("{\"type\":\"exponential\", \"lambda\":50}"));
  setup_rng("constant", cJSON_Parse("{\"type\":\"constant\", \"value\":100}"));
  setup_rng("uniform", cJSON_Parse("{\"type\":\"uniform\", \"min\":0, \"max\":100}"));
  setup_rng("normal", cJSON_Parse("{\"type\":\"normal\", \"mean\":100, \"std\":25}"));
}

int test_rng() {
  return 0;
}

int random_single_threaded_test() {
  int i = 0;
  printf("Exponential:\n");
  for(i; i < 100; i++) {
    printf("%f\n",get_random_number("exponential"));
  }
  return 0;
}

void *random_thr_test(void *args) {  
  return;
}

int random_multi_threaded_test() {
  pthread_t threads[1024];
  int i = 0;
  for(i; i < 1024; i++) {
    pthread_create(&threads[i], NULL, random_thr_test, NULL);
  }
  for(i=0; i < 1024; i++) {
    pthread_join(threads[i], NULL);
  }
}


int main() {
  printf("Starting Random Number Generator Tests:\n");
  random_setup_test();
  printf("Single threaded random numbers...\n");
  if(random_single_threaded_test() == 1) {
    printf("failed!\n");
  } 
  else {
    printf("passed.\n");
  }
  return 0;
}
